package car;

public class Car {
    private String brand;//品牌
    private String color;//颜色
    private float speed;//速度

    public Car() {
        this.brand = "夏利";
        this.color = "red";
        this.speed = 0;
    }

    public Car(String brand, String color, float speed) {
        this.brand = brand;
        this.color = color;
        this.speed = speed;
    }

    public String getBrand() {
        return brand;
    }

    public String getColor() {
        return color;
    }

    public float getSpeed() {
        return speed;
    }

    public void setSpeed(float speed) {
        this.speed = speed;
    }

    @Override
    public String toString() {
        return "Car.Car{" +
                "品牌：'" + this.getBrand() + '\'' +
                ", 颜色：'" + this.getColor() + '\'' +
                ", 当前速度：" + this.getSpeed() +
                '}';
    }
}

class test {
    public static void main(String[] args) {
        //调用无参构造
        Car car1 = new Car();
        //调用有参构造
        Car car2 = new Car("保时捷", "yellow", 60);
        System.out.println(car1);
        System.out.println(car2);
        //修改汽车速度
        car2.setSpeed(100);
        System.out.println(car2);
    }
}

/*
//测试==与equals的区别
class Car.test{
    public static void main(String[] args) {
        String s1=new String("123456");
        String s2=new String("123456");
        String s3=s1;

        System.out.println(s1==s2);//false
        System.out.println(s1.equals(s2));//true
        System.out.println(s1==s3);//true
        System.out.println(s1.equals(s3));//true
    }
}*/
